package com.sunday.common.statemachine.study.e2_Config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.statemachine.StateMachine;
import org.springframework.stereotype.Service;

/**
 * TODO
 *
 * @author sunday
 * @since 2024/12/3
 */
@Service
public class OrderService {

    @Autowired
    private StateMachine<OrderStates, OrderEvents> stateMachine;

    public void payForOrder() throws Exception {
        stateMachine.sendEvent(OrderEvents.PAY);
    }

    public void shipOrder() throws Exception {
        stateMachine.sendEvent(OrderEvents.SHIP);
    }

    public void completeOrder() throws Exception {
        stateMachine.sendEvent(OrderEvents.COMPLETE);
    }

    public void cancelOrder() throws Exception {
        stateMachine.sendEvent(OrderEvents.CANCEL);
    }

}
